package com.hyh.music.controller;

import com.hyh.music.Result.PageResult;
import com.hyh.music.Result.Result;
import com.hyh.music.domain.domainDTO.MessagePageDTO;
import com.hyh.music.domain.domains.ListSong;
import com.hyh.music.service.ListSongService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/admin/listSong")
public class ListSongController {

    @Autowired
    ListSongService listSongService;


    @GetMapping("/page")
    public Result<PageResult> Page(MessagePageDTO messagePageDTO){
        log.info("歌单分页查询{}",messagePageDTO);
        PageResult result =  listSongService.Page(messagePageDTO);
        return Result.success(result);
    }
    @DeleteMapping
    public Result deleteListSong(@RequestParam("ids") List<Integer> ids){
        log.info("删除歌单中的{}",ids);
        listSongService.delete(ids);
        return Result.success();
    }
    @GetMapping("add/{id}")
    public Result addListSong(@RequestParam("songIds") List<Integer> songIds , @PathVariable("id") Integer id){
        log.info("添加歌曲到歌单");
        listSongService.add(songIds , id);
        return Result.success();
    }


}
